package com.it.tydic.estate.module.controller.ckgl;

import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.Result;
import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.model.inner.TbCkglGys;
import com.it.tydic.estate.module.model.inner.TbCkglWplb;
import com.it.tydic.estate.module.service.GysService;
import com.it.tydic.estate.module.service.WplbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: 孟繁炫
 * @createDate: 2020/3/4
 * @version: 1.0
 */
@RestController
@RequestMapping("wplb")
@Api(tags = "仓库管理-物品类别接口")
public class WplbController {
    /**
     * 注入接口
     */
    @Autowired
    private WplbService wplbService;

    /**
     * 列表页面查询
     */
    @PostMapping("/pageList")
    @ApiOperation(value = "物品类别列表信息", notes = "物品类别列表信息")
    public Result pageList(@RequestBody Map<String,Object>map){
        return wplbService.pageList(map);
    }

    /**
     *  新增物品类别信息
     */
    @PostMapping("/insert")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @ApiOperation(value = "新增物品类别信息", notes = "新增物品类别信息")
    public Result insert(@RequestBody TbCkglWplb wplb){
        return wplbService.insertOrUpdate(wplb);
    }

    /**
     * 修改物品类别信息
     */
    @PostMapping("/update")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @ApiOperation(value = "修改物品类别信息", notes = "修改物品类别信息")
    public Result update(@RequestBody TbCkglWplb wplb){
        return wplbService.insertOrUpdate(wplb);
    }

    /**
     * 根据主键查询
     */
    @GetMapping("/getById/{id}")
    @ApiOperation(value = "根据id查询用", notes = "查询数据库中的某个物品类别")
    public Result getById(@RequestParam String id){
        return wplbService.getById(id);
    }

    /**
     * 根据ids 批量删除
     * @param ids 主键ids数组
     * @return
     */
    @ApiOperation("批量逻辑删除")
    @ControllerDesc(description = LogConstants.delete_data)
    @PostMapping("/deleteByIds")
    public Result deleteByIds(@RequestBody List<String> ids) {
        return wplbService.deleteByIds(ids);
    }
}
